package gui.Reportes.Ventas;

import gui.Reportes.Produccion.Reportes;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class ReporteVentasProducto extends javax.swing.JInternalFrame {
   
    private Date fechaInicio;
    private Date fechaFin;
    SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");
    private String ffi;
    private String fff;
   
   public ReporteVentasProducto() {
     initComponents();
        jdpInicio.setDate(new Date());
        jdpFin.setDate(new Date());
        
        Calendar calendar = jdpFin.getMonthView().getCalendar();
        calendar.setTime(jdpInicio.getDate());
        jdpFin.getMonthView().setLowerBound(calendar.getTime());
    }
   
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jdpInicio = new org.jdesktop.swingx.JXDatePicker();
        jLabel3 = new javax.swing.JLabel();
        btnVer = new javax.swing.JButton();
        jdpFin = new org.jdesktop.swingx.JXDatePicker();

        setClosable(true);
        setTitle("Generar Reporte Ventas por Producto");

        jLabel2.setText("Fecha Inicio:");

        jdpInicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jdpInicioActionPerformed(evt);
            }
        });

        jLabel3.setText("Fecha Fin:");

        btnVer.setText("Generar Reporte");
        btnVer.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(113, 113, 113)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jdpInicio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jdpFin, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(88, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnVer)
                .addGap(134, 134, 134))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jdpInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jdpFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(btnVer)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnVerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerActionPerformed
        this.fechaInicio = jdpInicio.getDate();
        this.fechaFin = jdpFin.getDate();
        this.ffi = sdf.format(fechaInicio);
        this.fff = sdf.format(fechaFin);

        Reportes r = new Reportes();
        r.mostrarReporteVentasProducto(ffi,fff);
    }//GEN-LAST:event_btnVerActionPerformed

    private void jdpInicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jdpInicioActionPerformed
        jdpFin.setDate(null);
        Calendar calendar = jdpFin.getMonthView().getCalendar();
        calendar.setTime(jdpInicio.getDate());
        jdpFin.getMonthView().setLowerBound(calendar.getTime());
    }//GEN-LAST:event_jdpInicioActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnVer;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    public org.jdesktop.swingx.JXDatePicker jdpFin;
    public org.jdesktop.swingx.JXDatePicker jdpInicio;
    // End of variables declaration//GEN-END:variables
}
